//
//  AccountManagementViewController.m
//  iStore
//
//  Created by Geek on 15/4/21.
//  Copyright (c) 2015年 mirrtalk. All rights reserved.
//

#import "AccountManagementViewController.h"
#import "AccountViewController.h"
#import "RechargeViewController.h"
#import "RequestEngine.h"


@interface AccountManagementViewController ()

@end

@implementation AccountManagementViewController


//- (void)viewWillAppear:(BOOL)animated
//{
//
////    sender.backgroundColor = KUnSelectedColor;
//
//
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账户管理";

    NSString *userID = [[NSUserDefaults standardUserDefaults]objectForKey:kUserId];
    NSDictionary * dic = @{@"userID":userID};
    [self activityStart];
    [RequestEngine RequestEngineWithDic:dic URL:@"money/checkMyMoney" completed:^(NSString *errorcode,NSDictionary *resultDict) {
        [self activityStop];

        if ([errorcode isEqualToString:@"0"]) {
            [self refresh:resultDict];
        }
    }];
    
    [_accountBtn setBackgroundImage:[UIImage imageNamed:@"Rectangle_6"] forState:UIControlStateHighlighted];
    [_reChargeButton setBackgroundImage:[UIImage imageNamed:@"Rectangle_6"] forState:UIControlStateHighlighted];
    
    
}


- (void)refresh:(NSDictionary*)dic
{
    _amount.text=[NSString stringWithFormat:@"%.2f元",[[dic objectForKey:@"historySum"] floatValue]];
    _balance.text=[NSString stringWithFormat:@"%.2f元",[[dic objectForKey:@"balance"] floatValue]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)recharge:(UIButton *)sender {
//    sender.backgroundColor = KSelectedColor;

    RechargeViewController * rVC = [[RechargeViewController alloc]init];
    [self.navigationController pushViewController:rVC animated:YES];
    
//    sender.backgroundColor = KUnSelectedColor;

}

- (IBAction)account:(UIButton *)sender {
//    sender.backgroundColor = KSelectedColor;

    AccountViewController *aVC = [[AccountViewController alloc]init];
    [self.navigationController pushViewController:aVC animated:YES];
    
//    sender.backgroundColor = KUnSelectedColor;

}
@end
